package com.zoweunion.mechanic.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


@Component

public class Tool {


	public static void main(String[] args) throws Exception{

//	AtomicInteger count = new AtomicInteger();
//
//	@RabbitHandler
//	@RabbitListener(queues = "q_hello")
//	public void process(String hello) {
//
//		count.getAndIncrement();
//
//		System.out.println("Receiver  : " + count.intValue());
//		System.out.println("Receiver  : " + hello);
//	}

		System.out.println(markOrderNo("A","1"));

//		Connection connection = ConnectionUtil.getConnection();
//
//		Channel channel = connection.createChannel();
//
//		// 声明（创建）队列
//		channel.queueDeclare(QUEUE_NAME, false, false, false, null);
//
//		// 消息内容
//		String message = "Hello World!";
//		channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
//		System.out.println(" [x] Sent '" + message + "'");
//		//关闭通道和连接
//		channel.close();
//		connection.close();
	}

	//生成订单号
	public static String markOrderNo(String platform,String order_type) {
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		int random = (int)((Math.random()*9+1)*1000);
		//platform:p是pc端创建的单子、I是苹果端创建的单子、A是安卓端创建的单子
		String orderNo = platform + order_type +df.format(new Date())+ String.valueOf(random);
		return orderNo;
	}

	public static String secretMobilePhone(String mobilePhone){
		char[] m = mobilePhone.toCharArray();
		for (int i = 0; i < m.length; i++) {
			if (i > 2 && i < 7) {
				m[i] = '*';
			}
		}
		return String.valueOf(m);
	}
}
